﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DAL;

/// <summary>
/// Description résumée de ProgrammeService
/// </summary>
/// 
namespace BLL
{
    public class ProgrammeService
    {
        private IProgrammeManager programmeManager;

        public ProgrammeService(IProgrammeManager programmeManager)
        {
            this.programmeManager = programmeManager;
        }

        public PROGRAMME createProgramme(int navireId, DateTime date)
        {
            PROGRAMME programme = new PROGRAMME();
            programme.NAVIREID = navireId;
            programme.DATE = date;

            try
            {
                programmeManager.addProgramme(programme);
                return programme;
            }

            catch (Exception ex)
            {
                return null;
            }

        }

        public bool deleteProgramme(int programmeId)
        {
            return programmeManager.deleteProgramme(programmeId);
        }


        public bool updateProgramme(int id, int navireId, DateTime date)
        {
            try
            {
                PROGRAMME programme = programmeManager.getProgrammeById(id);
                programme.NAVIREID = navireId;
                programme.DATE = date;

                programmeManager.updateProgramme();

                return true;
            }

            catch (Exception ex)
            {
                return false;
            }
        }

        public PROGRAMME getProgrammeById(int id)
        {
            return programmeManager.getProgrammeById(id);
        }

        public List<PROGRAMME> getAllProgrammes()
        {
            return programmeManager.getAllProgrammes();
        }

        public PROGRAMME getProgrammeForNavireAtDate(int navireId, DateTime date)
        {
            return programmeManager.getProgrammeForNavireAtDate(navireId, date);
        }

        public List<PROGRAMME> getProgrammesAtDate(DateTime date)
        {
            return programmeManager.getProgrammesAtDate(date);
        }

    }
}